#include "mylabel.h"

MyLabel::MyLabel(QWidget *parent) : QWidget(parent)
{
    this->setStyleSheet("background-color: rgba(255,255,255,1)");
    const QFont* name_font = new QFont("Microsoft YaHei", 8, 30);


    friendState = new QLabel();
    friendState->setParent(this);
    friendState->setStyleSheet("background-color: rgba(255,255,255,0)");
    friendState->setText("");
    friendState->setFont(*name_font);
    friendState->setGeometry(75,30,110,25);
    friendState->setFrameShape(QFrame::NoFrame);

    friendName = new QLabel();
    friendName->setParent(this);
    friendName->setStyleSheet("background-color: rgba(255,255,255,1)");
    friendName->setText("name");
    friendName->setFont(*name_font);
    friendName->setGeometry(0,0,180,65);
    friendName->setFrameShape(QFrame::NoFrame);
    // friendName->setMargin(3);
    friendName->setStyleSheet("QLabel:hover{background-color: rgba(255, 255, 255, 0);}");
    friendName->setAlignment(Qt::AlignHCenter);
    //friendName->setAlignment(Qt::AlignTop);

    QFont font;
    font.setPixelSize(17);
    friendName->setFont(font);

    friendPhoto = new QPushButton();
    friendPhoto->setParent(this);
    friendPhoto->setText("");
    friendPhoto->setGeometry(5,5,55,55);

}
void MyLabel::setLabel(QString str, int n){
    if (n == 0)
        friendName->setText(str.toUtf8() + "\n\n离线");
    else
        friendName->setText(str.toUtf8() + "\n\n在线");
}
void MyLabel::mouseDoubleClickEvent(QMouseEvent *event){
    emit sig_DoubleClick(friendName->text());
}

QString MyLabel::getName() const{
    return friendName->text();
}

void MyLabel::setStatus(int n){
    if(n==0)
        friendState->setText("离线");

    else
        friendState->setText("在线");
}
void MyLabel::setPhoto(int num){
    if (num == 0) {
        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/handsomeboy.jpg);border-radius:25px;}");
    }
    if (num == 1) {
        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/redhair.jpg);border-radius:25px;}");
    }
    if (num == 2) {

       friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/bearded.jpg);border-radius:25px;}");
    }
    if (num == 3) {

        friendPhoto->setStyleSheet("QPushButton{border-image: url(:/icon/bluedog.jpg);border-radius:25px;}");

    }
    if (num == 4) {

        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/baldman.jpg);border-radius:25px;}");
    }
    if (num == 5) {
        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/goddess.jpg);border-radius:25px;}");
    }
    if (num == 6) {

        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/greenQQ.png);border-radius:25px;}");
    }
    if (num == 7) {

        friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/huanqian.jpg);border-radius:25px;}");
    }
    if (num == 8) {
       friendPhoto->setStyleSheet("QPushButton{border-image: url(://icon/ourfaith.jpg);border-radius:25px;}");
    }
}
